public class Solution_125 {
    public boolean isPalindrome(String s) {
        int left = 0, right = s.length() - 1;
        s = s.toLowerCase();
        System.out.println(s);

        while (left < right) {
            char ch = s.charAt(left);
            if(!(('a' <= ch && ch <= 'z') || ('0' <= ch && ch <= '9'))) {
                left++;
                continue;
            }
            ch = s.charAt(right);
            if(!(('a' <= ch && ch <= 'z') || ('0' <= ch && ch <= '9'))) {
                right--;
                continue;
            }
            
            if(s.charAt(left) != s.charAt(right)) return false;
            
            left++;
            right--;
        }
        
        return true;
    }

    public static void main(String[] args) {
        String s = "race a car";
        System.out.println(new Solution_125().isPalindrome(s));
    }
}
